﻿//统一文件为utf-8编码编译
#pragma execution_character_set("utf-8")
///////////////////////////////////////////////////////////////////////////
// 文件名:     SpectrogramView.cpp
// 描述:
// 作者:      颜磊
// 创建工程：   AudioComment
// 创建时间:   2024-06-26 12:33
///////////////////////////////////////////////////////////////////////////
#include "spectrogramview.h"

#include <QPainter>
#include <QDebug>
#include <qcolorgradient.h>
#include <QMouseEvent>
#include <QThread>
#include "signalspectrum.h"
#include "wavfiletools.h"

SpectrogramView::SpectrogramView(QWidget *parent) : QOpenGLWidget(parent)
{
    setMouseTracking(true);
    fftLen = 128;

    markLineX = 0;
    toppadding=10;
    leftpadding=30;
    rightpadding=30;
    bottompadding=30;
    //颜色设置
    backColor = QColor(40, 40 , 40, 255);
    lineColor = QColor(70, 70 , 70, 255);

    minX=0;
    maxX=50;
    showMinX=10;
    showMaxX=20;
    lineNumX=10;//线数量
    minShowRangeX=1;//最小显示范围
    maxShowRangeX=0;//最大显示范围
    singleStepX = 1.0;
    valuePostfixX = "S";//后缀
    precX=3;//保留小数位
    valueColorX = Qt::white;//标志颜色
    valueFontX = QFont("SimSun",8,QFont::Bold);//内容字体

    moveSelectX = false;
    selectedX = false;
    moveX = false;
    anX =false;

    setleveled = false;
    minLevel = 0;
    maxLevel = 125;
    tempFullImage = QImage(width(),fftLen,QImage::Format_RGB32);
    fullImage = QImage(width(),fftLen,QImage::Format_RGB32);

    colorMap.insert(0,QColor(Qt::black));
    colorMap.insert(0.4,QColor(Qt::black));
    colorMap.insert(0.5,QColor(Qt::blue));
    colorMap.insert(0.6,QColor(Qt::red));
    colorMap.insert(0.8,QColor(Qt::yellow));
    colorMap.insert(0.9,QColor(Qt::white));
    colorMap.insert(1,QColor(Qt::white));
    QColorGradient colorGradient;
    colorGradient.setColorMap(colorMap);
    colorList = colorGradient.getColorList(125);
    //    reSizeRect();
    //=======================================线程相关
    drawing = false;
    queueDisposeThreadRun = true;
    queueDisposeThread = std::thread(&SpectrogramView::drawRequestQueueDispose,this);

    connect(this,&SpectrogramView::signal_update,this,&SpectrogramView::slot_update);
    connect(this,&SpectrogramView::signal_drawing,this,&SpectrogramView::slot_drawing);

}
SpectrogramView::~SpectrogramView()
{
    queueDisposeThreadRun = false;
    if(queueDisposeThread.joinable()){
        queueDisposeThread.join();
    }
    drawViewThreadRun = false;
    if(drawViewThread.joinable()){
        drawViewThread.join();
    }
}
void SpectrogramView::reSizeRect()
{
    viewRect = QRect(QPoint(leftpadding,toppadding),QPoint(width()-rightpadding,height()-bottompadding));
    xRect = QRect(QPoint(leftpadding,height()-bottompadding),QPoint(width()-rightpadding,height()));

    fullImgMutex.lock();
    tempFullImage = tempFullImage.scaled(viewRect.width(),fftLen,Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
    fullImage = tempFullImage.copy(0,0,tempFullImage.width(),tempFullImage.height());
    fullImgMutex.unlock();
}

QMap<double, QColor> SpectrogramView::getColorMap() const
{
    return colorMap;
}

void SpectrogramView::setColorMap(const QMap<double, QColor> &value)
{
    colorMap = value;
}

bool SpectrogramView::getSetleveled() const
{
    return setleveled;
}

void SpectrogramView::setMarkBandList(const QList<MarkBand> &value)
{
    markBandList = value;
    signal_update();
}

void SpectrogramView::setMarkLineX(double value)
{
    markLineX = value;
    signal_update();
}

void SpectrogramView::addDrawRequest()
{
    drawRequestQueueMutex.lock();
    drawRequestQueue.push_back(1);
    drawRequestQueueMutex.unlock();

}

void SpectrogramView::drawView()
{
    reSizeRect();
    if(QString(fileParam.filePath).isEmpty()){
        drawErrorText();
        return;
    }
    QFile file(fileParam.filePath);

    if(file.open(QFile::ReadOnly)){
        setDrawing(true);
        void *spectrum;
        Spectrum_Open((void**)&spectrum,fftLen,WIN_Blackman,fileParam.channleNumber == 1 ? R2FFT : C2FFT);
        uint64_t startIndex = WavFileTools::timeToIndex(fileParam.sampleRate,fileParam.channleNumber,fileParam.bitsPerSample,showMinX);
        uint64_t stopIndex = WavFileTools::timeToIndex(fileParam.sampleRate,fileParam.channleNumber,fileParam.bitsPerSample,showMaxX);

        int sampleBytes = (fileParam.bitsPerSample/8); //单个样点字节长度

        uint64_t startSample = startIndex/2;//起始样点
        uint64_t stopSample = stopIndex/2;//结束样点

        if(viewRect.width() == 0){
            qDebug() << "error" << "viewRect.width() = 0";
        }

        uint64_t sampleLen = (stopSample - startSample);//样点总数
        uint64_t fftNum = sampleLen / (fftLen * 2);//可以做fft的次数

        int oneReadLen = fftLen * 2;//单次FFT所需样点长度

        double step = (double)fftNum / viewRect.width();//读取次数步进
        int sampleStep = floor(oneReadLen * step); //样点步进
        int needReadLen = oneReadLen * ceil(step);//输入FFT样点长度

        QVector<short> readData;
        QVector<short> fftData;
        fftData.resize(fftLen);
        readData.resize(needReadLen);
        //求取值范围
//        if(!getSetleveled()){
//            qDebug() << "计算范围";
//            bool isFrist = true;
//            short minLevel = 0;
//            short maxLevel = 0;
            //画图
//            for(int i=0;i<viewRect.width() && drawViewThreadRun;i++){
//                uint64_t readIndex = i * sampleStep * sampleBytes + startSample * sampleBytes + fileParam.headerLen;
//                file.seek(readIndex);
//                file.read((char*)readData.data(),needReadLen * sampleBytes); //暂时未处理读取到末尾不够读取
//                //fft处理，
//                Spectrum_ConversionMAX(spectrum,readData.data(),readData.size(),fftData.data());
//                fftData[i] = fftData[i+1];
//                //绘图
//                auto autoMinVal = std::min_element(fftData.begin(),fftData.end());
//                auto autoMaxVal = std::max_element(fftData.begin(),fftData.end());
//                short minVal = 0;
//                short maxVal = 0;
//                if(autoMinVal != fftData.end()){
//                    minVal = *autoMinVal;
//                }
//                if(autoMaxVal != fftData.end()){
//                    maxVal = *autoMaxVal;
//                }


//                qDebug() << minVal << maxVal;
//                if(minVal < -255 || maxVal > 255) continue;
//                if(isFrist){
//                    minLevel = minVal;
//                    maxLevel = maxVal;
//                    isFrist = false;
//                }else{
//                    if(minVal < minLevel){
//                        minLevel = minVal;
//                    }
//                    if(maxVal > maxLevel){
//                        maxLevel = maxVal;
//                    }
//                }
                //                QThread::usleep(1);
//            }
//            setLevelRange(minLevel,maxLevel);
//            qDebug() << minLevel << maxLevel;
//            qDebug() << "计算范围结束";
//        }
        //画图
//        qDebug() << "画图";
        for(int i=0;i<viewRect.width() && drawViewThreadRun;i++){
            uint64_t readIndex = i * sampleStep * sampleBytes + startSample * sampleBytes + fileParam.headerLen;
            file.seek(readIndex);
            file.read((char*)readData.data(),needReadLen * sampleBytes); //暂时未处理读取到末尾不够读取
            //fft处理，
            Spectrum_ConversionMAX(spectrum,readData.data(),readData.size(),fftData.data());
            //绘图
           drawSpectrogramView(i,fftData);
//           QThread::usleep(1);
        }
        file.close();
        Spectrum_Close(spectrum);
        setDrawing(false);
//        qDebug() << "画图结束";
    }else{
        //错误处理
    }
}

void SpectrogramView::drawRequestQueueDispose()
{
    while (queueDisposeThreadRun) {
        //        qDebug() << "检查是否有重绘制请求";
        if(drawRequestQueueMutex.try_lock()){
            if(drawRequestQueue.size() > 0){
                //等待绘制线程结束
                //            if(drawing){
                //                qDebug() << "等待绘制线程结束";
                //                drawViewThreadRun = false;
                //            }
                //qDebug() << "等待绘制线程结束";
                drawViewThreadRun = false;
                if(drawViewThread.joinable())
                    drawViewThread.join();
                //启动绘制
                //qDebug() << "启动绘制";
                drawViewThreadRun = true;
                drawViewThread = std::thread(&SpectrogramView::drawView,this);
                //请空队列
                //qDebug() << "请空队列";
                drawRequestQueue.clear();
            }
            drawRequestQueueMutex.unlock();
        }
        QThread::msleep(10);
    }
}

void SpectrogramView::setFileParam(const AudioFileParam &value)
{
    setfileParamed = true;
    fileParam = value;
    double totalTime =  WavFileTools::indexToTime(fileParam.sampleRate,fileParam.channleNumber,fileParam.bitsPerSample,fileParam.fileDataSize);
    setRangeX(0,totalTime);
    addDrawRequest();
}

void SpectrogramView::setDrawing(bool value)
{
    signal_drawing(value);
}

double SpectrogramView::getShowMaxX() const
{
    return showMaxX;
}

void SpectrogramView::setShowMaxX(double value)
{
    showMaxX = value;
    signal_update();
}

void SpectrogramView::setFftLen(int value)
{
    fftLen = value;
    addDrawRequest();
}

void SpectrogramView::setLevelRange(int m_minLevel, int m_maxLevel)
{
    setleveled = true;
    if(m_minLevel != m_maxLevel){
        minLevel = m_minLevel;
        maxLevel = m_maxLevel;
        QColorGradient colorGradient;
        colorGradient.setColorMap(colorMap);
        colorList = colorGradient.getColorList(maxLevel - minLevel);
    }
}

void SpectrogramView::drawSpectrogramView(int index, QVector<short> fftData)
{
    fullImgMutex.lock();
    if(index > tempFullImage.width()) return;
    if(colorList.size() < 1) return;
//    qDebug() << colorList.size() << tempFullImage.width() << tempFullImage.height();
    for (int i = 0; i < fftData.size(); i++) {
        short currentValue = fftData.at(i);
        int coloIndex = (currentValue - minLevel);
        if(coloIndex < 0) coloIndex = 0;
        if(coloIndex >= colorList.size()) coloIndex = colorList.size()-1;
        tempFullImage.setPixel(QPoint(index,fftData.size()-i-1),colorList.at(coloIndex).rgba());
    }
//    fullImage = tempFullImage.copy(0,0,tempFullImage.width(),tempFullImage.height());

    fullImgMutex.unlock();

    if(fullImgMutex.try_lock()){
        fullImage = tempFullImage.copy(0,0,tempFullImage.width(),tempFullImage.height());
        fullImgMutex.unlock();
    }
    signal_update();
}

void SpectrogramView::drawErrorText()
{
    QPainter p(&tempFullImage);
    p.setPen(QColor(Qt::white));
    QFont font = p.font();
    font.setPixelSize(30);
    p.setFont(font);
    p.setBrush(backColor);
    p.drawRect(rect());
    p.drawText(tempFullImage.rect(),Qt::AlignCenter,"中科星光@提示：请设置文件相关参数！");
    if(fullImgMutex.try_lock()){
        fullImage = tempFullImage.copy(0,0,tempFullImage.width(),tempFullImage.height());
        fullImgMutex.unlock();
    }
    signal_update();
}

void SpectrogramView::slot_update()
{
    update();
}

void SpectrogramView::slot_drawing(bool b)
{
    drawing = b;
    if(drawing){
        //qDebug() << "正在加载...";
        setCursor(Qt::WaitCursor);
    }else{
        //qDebug() << "正在完成";
        setCursor(Qt::ArrowCursor);
    }
}

double SpectrogramView::getShowMinX() const
{
    return showMinX;
}

void SpectrogramView::setShowMinX(double value)
{
    showMinX = value;
    signal_update();
}

double SpectrogramView::getMinX() const
{
    return minX;
}

void SpectrogramView::setMinX(double value)
{
    minX = value;
    signal_update();
}

void SpectrogramView::setRangeX(double m_minX, double m_maxX)
{
    minX = m_minX;
    maxX = m_maxX;
    showMinX = minX;
    showMaxX = maxX;
    signal_update();
}

void SpectrogramView::setSelectRangeX(double minX, double maxX)
{
    selectBeginX = minX;
    selectEndX = maxX;
    selectedX = (minX != maxX);
    signal_update();
}

double SpectrogramView::getMaxX() const
{
    return maxX;
}

void SpectrogramView::setMaxX(double value)
{
    maxX = value;
    signal_update();
}

void SpectrogramView::paintBg(QPainter &p)
{
    p.setPen(Qt::NoPen);
    p.setBrush(backColor);
    p.drawRect(rect());
}

void SpectrogramView::paintLineX(QPainter &p)
{
    p.setPen(QPen(QBrush(lineColor), 1, Qt::SolidLine));
    for(int i=0;i<lineNumX+1;i++){//主纵线
        p.drawLine(QPoint(i*(viewRect.width()/lineNumX)+leftpadding,toppadding),QPoint(i*(viewRect.width()/lineNumX)+leftpadding,height()-bottompadding));
    }
}

void SpectrogramView::paintValueX(QPainter &p)
{
    //字体是否加粗
    p.setFont(valueFontX);
    p.setPen(valueColorX);

    int drawHeight = height();
    drawHeight =  (height()-toppadding-bottompadding);
    for(int i=0;i<lineNumX+1;i++){
        p.drawText(QRectF((width()-(leftpadding+rightpadding))*i/lineNumX+leftpadding-(width()-leftpadding-rightpadding)/lineNumX/2,
                          toppadding+drawHeight+1,(width()-leftpadding-rightpadding)/lineNumX,bottompadding), Qt::AlignCenter,
                   QString::number(showMinX+i*qAbs(showMaxX-showMinX)/lineNumX,'f',precX)+valuePostfixX);
    }
}

void SpectrogramView::paintSpectrogram(QPainter &p)
{
    fullImgMutex.lock();
    p.drawImage(viewRect,fullImage);
    fullImgMutex.unlock();
}

void SpectrogramView::paintAnX(QPainter &p)
{
    if(anX){
        QLinearGradient linearGradient;
        linearGradient.setStart(0,0);
        linearGradient.setFinalStop(0,1);
        linearGradient.setColorAt(0.0,QColor(0,0,255,150));
        linearGradient.setColorAt(0.5,QColor(0,0,100,100));
        linearGradient.setColorAt(1,QColor(0,0,255,150));
        p.setBrush(QBrush(linearGradient));
        if(endPos.x()>beginPos.x())
            p.drawRect(beginPos.x(),toppadding ,endPos.x()-beginPos.x(),height()-toppadding);
        else
            p.drawRect(endPos.x(), toppadding,beginPos.x()-endPos.x(), height()-toppadding);
    }
}

void SpectrogramView::paintSelectX(QPainter &p)
{
    if(selectedX){
        QLinearGradient linearGradient;
        int s_x,s_y,s_width,s_height;

        s_x = (selectBeginX-showMinX)/(showMaxX-showMinX)*viewRect.width()+leftpadding;
        s_y = toppadding;
        s_width=(selectEndX-selectBeginX)/(showMaxX-showMinX)*viewRect.width();
        s_height = viewRect.height();

        //s_height = (topLevel - selectBottomLevel)/(topLevel-bottomLevel)*fftRect.height()+toppadding - s_y;

        linearGradient.setStart(s_x,0);
        linearGradient.setFinalStop(s_x+s_width,0);
        linearGradient.setColorAt(0.0,QColor(0,0,255,150));
        linearGradient.setColorAt(0.5,QColor(0,0,100,100));
        linearGradient.setColorAt(1,QColor(0,0,255,150));
        p.setBrush(QBrush(linearGradient));
        p.drawRect(s_x, s_y,s_width, s_height);
    }
}

void SpectrogramView::paintMarkLineX(QPainter &p)
{
    if(markLineX > showMinX && showMinX < showMaxX){
        p.setPen(QColor(Qt::yellow));
        int s_x = (markLineX-showMinX)/(showMaxX-showMinX)*viewRect.width()+leftpadding;
        p.drawLine(s_x,viewRect.top(),s_x,xRect.bottom());
    }

}

void SpectrogramView::paintMarkBand(QPainter &p)
{
    QLinearGradient linearGradient;
    int s_x,s_y,s_width,s_height;
    for (int i=0;i<markBandList.size();i++) {
        s_x = (markBandList.at(i).startX-showMinX)/(showMaxX-showMinX)*viewRect.width()+leftpadding;
        s_y = toppadding;

        s_width=(markBandList.at(i).stopX-markBandList.at(i).startX)/(showMaxX-showMinX)*viewRect.width();
        s_height = viewRect.height();

        linearGradient.setStart(s_x,0);
        linearGradient.setFinalStop(s_x+s_width,0);
        linearGradient.setColorAt(0.0,QColor(20,20,20,150));
        linearGradient.setColorAt(1,QColor(20,20,20,150));
        //        p.setBrush(QBrush(linearGradient));
        p.setBrush(Qt::NoBrush);
        p.drawRect(s_x, s_y,s_width, s_height);
    }
}

void SpectrogramView::mousePressEvent(QMouseEvent *event)
{
    if(viewRect.contains(event->pos())){
        if(event->buttons()==Qt::LeftButton){
            moveSelectX = true;
            selectBeginX=showMinX+((double)(beginPos.x()-leftpadding)/(double)viewRect.width())*qAbs(showMinX-showMaxX);
            selectEndX=selectBeginX;
            selectedX = false;
        }
    }
    if(xRect.contains(event->pos())){
        //qDebug()<< "在fft频率区域";
        if(event->buttons()==Qt::LeftButton){
            //moveX = !drawing;
            moveX = true;
        }else if(event->buttons()==Qt::RightButton){
            //anX = !drawing;
            anX = true;
        }
    }
    beginPos=event->pos();
    QOpenGLWidget::mouseMoveEvent(event);
}

void SpectrogramView::mouseMoveEvent(QMouseEvent *event)
{
    nowPos = event->pos();
    if(moveSelectX){
        double wanthFreq=qAbs(showMinX-showMaxX);
        if(nowPos.x()>beginPos.x()){
            selectBeginX=showMinX+((double)(beginPos.x()-leftpadding)/(double)viewRect.width())*wanthFreq;
            selectEndX=showMinX+((double)(nowPos.x()-leftpadding)/(double)viewRect.width())*wanthFreq;
        }else{
            selectBeginX=showMinX+((double)(nowPos.x()-leftpadding)/(double)(width()-(leftpadding+rightpadding)))*wanthFreq;
            selectEndX=showMinX+((double)(beginPos.x()-leftpadding)/(double)(width()-(leftpadding+rightpadding)))*wanthFreq;
        }
        selectedX = (selectEndX != selectBeginX);
        signal_update();
    }
    if(moveX){//移动X轴
        setCursor(Qt::SplitHCursor);
        if(nowPos.x()<beginPos.x()){//向左移动
            double num=(qAbs(showMinX-showMaxX)*qAbs(nowPos.x()-beginPos.x())/viewRect.width());// (width()-(leftpadding+rightpadding)));
            if((showMaxX+num)>maxX){
                showMinX+=maxX-showMaxX;
                showMaxX=maxX;
            }else{
                showMinX+=num;
                showMaxX+=num;
            }
        }else{//向右移动
            double num=(qAbs(showMinX-showMaxX)*qAbs(nowPos.x()-beginPos.x())/viewRect.width());//(width()-(leftpadding+rightpadding)));
            if((showMinX-num)<minX){
                showMaxX-=showMinX-minX;
                showMinX=minX;
            }else{
                showMinX-=num;
                showMaxX-=num;
            }
        }
        signal_update();
        beginPos=nowPos;
    }
    endPos=event->pos();
    if(anX){
        signal_update();
    }
    QOpenGLWidget::mouseMoveEvent(event);
}

void SpectrogramView::mouseReleaseEvent(QMouseEvent *event)
{
    endPos=event->pos();
    moveSelectX = false;
    signal_changeSelectState(selectedX);
    if(selectedX){
        signal_changeSelectRange(selectBeginX,selectEndX);
    }
    if(moveX){
        addDrawRequest();
    }
    if(anX){
        double lFreq,rFreq;
        if(beginPos.x()>endPos.x()){
            double wanthFreq=qAbs(showMinX-showMaxX);
            rFreq=showMinX+((double)(beginPos.x()-leftpadding)/(double)xRect.width())*wanthFreq;
            lFreq=showMinX+((double)(endPos.x()-leftpadding)/(double)xRect.width())*wanthFreq;
        }else{
            double wanthFreq=qAbs(showMinX-showMaxX);
            rFreq=showMinX+((double)(endPos.x()-leftpadding)/(double)xRect.width())*wanthFreq;
            lFreq=showMinX+((double)(beginPos.x()-leftpadding)/(double)xRect.width())*wanthFreq;
        }
        if(rFreq - lFreq >= minShowRangeX){
            showMaxX = rFreq;
            showMinX = lFreq;
            if(rFreq > maxX){
                showMaxX = maxX;
            }
            if(lFreq < minX){
                showMinX = minX;
            }
            addDrawRequest();
        }
    }
    moveX = false;
    anX=false;
    signal_update();
    if(drawing){
        setCursor(Qt::WaitCursor);
    }else{
        setCursor(Qt::ArrowCursor);
    }
    QOpenGLWidget::mouseReleaseEvent(event);
}

void SpectrogramView::paintEvent(QPaintEvent *event)
{
    QPainter p(this);
    paintBg(p);
    paintLineX(p);
    paintValueX(p);
    paintSpectrogram(p);
    paintAnX(p);
    paintMarkBand(p);
    paintSelectX(p);
    paintMarkLineX(p);
//    QOpenGLWidget::paintEvent(event);
}

void SpectrogramView::wheelEvent(QWheelEvent *event)
{
    //if(!drawing){
    if(true){
        if(viewRect.contains(event->pos()) || xRect.contains(event->pos())){
            if (event->delta() > 0){//向上 放大 （缩小起始范围）
                double num=singleStepX;
                if(minShowRangeX != 0 && (showMaxX - showMinX - num < minShowRangeX))
                    num = showMaxX - showMinX - minShowRangeX;
                if(num == 0) num = 0;
                double leftnum=num*(nowPos.x()-leftpadding)/(width()-(leftpadding+rightpadding));
                double rightnum=num-leftnum;
                showMinX+=leftnum;
                showMaxX-=rightnum;
            }else{//向下 缩小（放大起始频率)
                double num=singleStepX;
                if(maxShowRangeX != 0 && (showMaxX - showMinX + num > maxShowRangeX))
                    num = maxShowRangeX - (showMaxX - showMinX);
                if(num == 0) num = 0;
                double leftnum=num*(nowPos.x()-leftpadding)/(width()-(leftpadding+rightpadding));
                double rightnum=num-leftnum;
                if((showMinX-leftnum)<minX){
                    showMinX=minX;
                }
                else{
                    showMinX-=leftnum;
                }
                if((showMaxX+rightnum)>maxX){
                    showMaxX=maxX;
                }else{
                    showMaxX+=rightnum;
                }
            }
            signal_update();
            addDrawRequest();
        }
    }
    QOpenGLWidget::wheelEvent(event);
}

void SpectrogramView::keyPressEvent(QKeyEvent *event)
{

    QOpenGLWidget::keyPressEvent(event);
}

void SpectrogramView::keyReleaseEvent(QKeyEvent *event)
{

    QOpenGLWidget::keyReleaseEvent(event);
}

void SpectrogramView::enterEvent(QEvent *event)
{
    signal_update();
    QOpenGLWidget::enterEvent(event);
}

void SpectrogramView::leaveEvent(QEvent *event)
{

    signal_update();
    QOpenGLWidget::leaveEvent(event);
}

void SpectrogramView::mouseDoubleClickEvent(QMouseEvent *event)
{
    if(viewRect.contains(event->pos()) || xRect.contains(event->pos())){
        showMinX = minX;
        showMaxX = maxX;
        addDrawRequest();
        signal_update();
    }
    QOpenGLWidget::mouseDoubleClickEvent(event);
}

void SpectrogramView::resizeEvent(QResizeEvent *event)
{
    //    reSizeRect();
    addDrawRequest();
    QOpenGLWidget::resizeEvent(event);
}


